
from fastapi import APIRouter, HTTPException, Path
from api.deps import SessionDep
from services import order_initial_service
from schemas.response_schema import R
from schemas.order_initial_schema import OrderInitialPublic
from services.exception import BusinnessStatus
router = APIRouter()

@router.get("/{order_code}",
            summary="通过订单号查询订单信息",
            response_model=R[OrderInitialPublic])
async def get_order_initial_by_order_code(*,session:SessionDep,
                    order_code:str=Path(summary="订单号",example="123456789")):
    "通过订单号查询订单信息"
    order_initial = await order_initial_service.find_order_initial_by_order_code(session=session,order_code=order_code)
    if order_initial is None:
        raise HTTPException(404,"订单不存在")
    return R.success(data=order_initial)


